package com.archstoday.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.archstoday.R;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * 消息适配器
 */
public class MessageAdapter extends BaseAdapter {

    private Context mContext;

    public MessageAdapter(Context context) {
        mContext = context;
    }

    @Override
    public int getCount() {
        return 5;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        Holder holder;
        if (view == null) {
            holder = new Holder();
            view = LayoutInflater.from(mContext).inflate(R.layout.item_message, null);
            holder.headIcon = (CircleImageView) view.findViewById(R.id.item_head_icon);
            holder.nameTv = (TextView) view.findViewById(R.id.item_name_tv);
            holder.messageTv = (TextView) view.findViewById(R.id.item_message_tv);
            holder.timeTv = (TextView) view.findViewById(R.id.item_time_tv);

            view.setTag(holder);
        } else {
            holder = (Holder) view.getTag();
        }

        holder.nameTv.setText("名字");
        holder.messageTv.setText("消息内容");
        holder.timeTv.setText("12-12");

        return view;
    }

    class Holder {
        CircleImageView headIcon;
        TextView nameTv, messageTv, timeTv;
    }
}